<template>
  <div class="index-container">
    <!-- //顶部搜索和右上侧表格特效 -->
    <el-form
      ref="form"
      class="demo-form-inline"
      :inline="true"
      :model="queryForm"
      @submit.native.prevent
    >
      <el-form-item>
        <el-select v-model="value1" placeholder="骑行区域">
          <el-option
            v-for="item in options1"
            :key="item.value"
            aria-setsize="medium"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select v-model="value1" placeholder="订单状态">
          <el-option
            v-for="item in options1"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select v-model="value1" placeholder="车辆状态">
          <el-option
            v-for="item in options1"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-input v-model="queryForm.order" clearable placeholder="订单号" />
      </el-form-item>
      <el-form-item>
        <el-input v-model="queryForm.rate" clearable placeholder="车牌号" />
      </el-form-item>
      <el-form-item>
        <el-input v-model="queryForm.phone" placeholder="手机号" />
      </el-form-item>
      <el-form-item>
        <el-select v-model="value1" placeholder="是否有调度费">
          <el-option
            v-for="item in options1"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select v-model="value1" placeholder="商户">
          <el-option
            v-for="item in options1"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select v-model="value1" placeholder="是否返还费用">
          <el-option
            v-for="item in options1"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-input v-model="queryForm.rate" clearable placeholder="备注" />
      </el-form-item>
      <el-form-item>
        <el-date-picker
          end-placeholder="订单创建-结束"
          range-separator="至"
          start-placeholder="订单创建-开始"
          type="datetimerange"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          icon="el-icon-search"
          native-type="submit"
          type="primary"
          @click="handleQuery"
        >
          查询
        </el-button>
        <el-button icon="el-icon-plus" type="primary" @click="handleAdd">
          添加
        </el-button>
        <el-button icon="el-icon-delete" type="danger" @click="handleDelete">
          删除
        </el-button>
      </el-form-item>
    </el-form>
    <!-- 表格体部分 -->
    <el-table
      ref="tableSort"
      v-loading="listLoading"
      :border="border"
      :data="list"
      :height="height"
      :size="lineHeight"
      :stripe="stripe"
      @selection-change="setSelectRows"
    >
      <el-table-column align="center" type="selection" width="55" />
      <el-table-column
        align="center"
        label="序号"
        show-overflow-tooltip
        width="55"
      >
        <!-- 序号内容的列 -->
        <template #default="{ $index }">
          {{ $index + 1 }}
        </template>
      </el-table-column>
      <el-table-column
        v-for="(item, index) in finallyColumns"
        :key="index"
        align="center"
        :label="item.label"
        :sortable="item.sortable"
      >
        <!-- 的列 -->
        <template #default="{ row }">
          <span>{{ row[item.prop] }}</span>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="操作"
        show-overflow-tooltip
        width="85"
      >
        <template #default="{ row }">
          <el-button type="text" @click="handleEdit(row)">详情</el-button>
          <el-button type="text" @click="handleDelete(row)">删除</el-button>
        </template>
      </el-table-column>
      <template #empty>
        <el-image
          class="vab-data-empty"
          :src="require('@/assets/empty_images/data_empty.png')"
        />
      </template>
    </el-table>
    <!-- 这个是底部页面跳转内容 -->
    <el-pagination
      background
      :current-page="queryForm.pageNo"
      :layout="layout"
      :page-size="queryForm.pageSize"
      :total="total"
      @current-change="handleCurrentChange"
      @size-change="handleSizeChange"
    />
    <table-edit ref="edit" @fetch-data="fetchData" />
  </div>
</template>

<script>
  import { getList } from '@/api/table'
  import TableEdit from './components/TableEdit'

  export default {
    name: 'Order',
    components: {
      // 需要外部的两个组件
      TableEdit,
    },
    data() {
      return {
        layout: 'total, sizes, prev, pager, next, jumper',
        total: 0,
        selectRows: '',
        // 初始状态下跳转页面的数据
        queryForm: {
          pageNo: 0,
          pageSize: 20,
          title: '',
        },
      }
    },
    methods: [getList],
  }
</script>

//
<style lang="scss" scoped>
  .custom-table-container {
    ::v-deep {
      i {
        cursor: pointer;
      }
    }
    .stripe-panel,
    .border-panel {
      margin: 0 10px $base-margin 10px !important;
    }
  }
</style>
//
<style lang="scss">
  .custom-table-checkbox {
    [class*='ri'] {
      vertical-align: -2.5px;
      cursor: pointer;
    }

    .el-checkbox {
      margin: 5px 0 5px 8px;
    }
  }
</style>
<style>
  .vab-query-form-left-panel {
    border: 2px solid red !important;
  }
  .vab-query-form-right-panel {
    border: 1px solid yellow;
  }
</style>
